package org.rambadger.command.command;

import org.axonframework.commandhandling.annotation.TargetAggregateIdentifier;
import org.hibernate.validator.constraints.Email;
import org.hibernate.validator.constraints.Length;
import org.hibernate.validator.constraints.NotBlank;
import org.rambadger.command.validation.UrlIdentifier;

import javax.validation.constraints.NotNull;

/**
 * {@link org.rambadger.command.command Command} class for creating new {@link org.rambadger.command.model.UserAggregate Users}.
 */
public class RegisterNewUser {
    @TargetAggregateIdentifier
    private final String username;
    private final String passwordHash;
    private final String emailAddress;
    private final String firstName;
    private final String lastName;

    /**
     * Instantiates a new RegisterNewUser command
     *
     * @param username the username
     * @param passwordHash the password hash
     * @param emailAddress the user's email address
     * @param firstName the first name, may be empty
     * @param lastName the last name, may be empty
     */
    public RegisterNewUser(String username, String passwordHash, String emailAddress, String firstName, String lastName) {
        this.username = username;
        this.passwordHash = passwordHash;
        this.emailAddress = emailAddress;
        this.firstName = firstName;
        this.lastName = lastName;
    }

    /**
     * Gets username.
     * <p>
     * The username is used for logins, URLs, database IDs
     *
     * @return the username
     */
    @UrlIdentifier @NotNull
    public String getUsername() {
        return username;
    }

    /**
     * Gets password hash.
     *
     * @return the password hash
     */
    @NotNull
    public String getPasswordHash() {
        return passwordHash;
    }

    /**
     * Gets email address.
     *
     * @return the email address
     */
    @Email @NotBlank
    public String getEmailAddress() {
        return emailAddress;
    }

    /**
     * Gets first name.
     *
     * @return the first name
     */
    @Length(max = 32) @NotNull
    public String getFirstName() {
        return firstName;
    }

    /**
     * Gets last name.
     *
     * @return the last name
     */
    @Length(max = 32) @NotNull
    public String getLastName() {
        return lastName;
    }

}
